package cn.wolfcode.config;

import cn.wolfcode.web.Interceptor.LoginInterceptor;
import cn.wolfcode.web.Interceptor.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;
    @Autowired
    private PermissionInterceptor permissionInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册登录拦截器
        registry.addInterceptor(loginInterceptor)
                // 对哪些资源起过滤作用
                .addPathPatterns("/**")
                // 对哪些资源起排除作用
                .excludePathPatterns("/empLogin","/login.html","/index","/appointment/save","/css/**","/js/**","/img/**");
        // 注册登录拦截器
        registry.addInterceptor(permissionInterceptor)
                // 对哪些资源起过滤作用
                .addPathPatterns("/**")
                // 对哪些资源起排除作用
                .excludePathPatterns("/empLogin","/login.html","/index","/appointment/save","/css/**","/js/**","/img/**");
    }
}
